Getting Started with RFID by Tom Igoe

Getting Started with RFID by Tom Igoe

Author:Tom Igoe [Tom Igoe]
Language: eng
Format: epub, pdf
Tags: COMPUTERS / Data Transmission Systems / Wireless
ISBN: 9781449324131
Publisher: O'Reilly Media
Published: 2012-03-08T16:00:00+00:00


Try It

This sketch reads in bytes similar to the Processing sketches shown in Chapter 2. Upload it to your Arduino, launch the Arduino Serial Monitor (Tools→Serial Monitor), and make sure the Serial Monitor is configured for 9600 bps. Next, bring an RFID tag within range of the reader, and you should see the tag ID appear in the Serial Monitor window.

/* RFID Reader */ #include <SoftwareSerial.h> // Bring in the software serial library const int tagLength = 10; // each tag ID contains 10 bytes const int startByte = 0x0A; // Indicates start of a tag const int endByte = 0x0D; // Indicates end of a tag char tagID[tagLength + 1]; // array to hold the tag you read const int rxpin = 6; // Pin for receiving data from the RFID reader const int txpin = 7; // Transmit pin; not used SoftwareSerial rfidPort(rxpin, txpin); // create a Software Serial port void setup() { // begin serial communication with the computer Serial.begin(9600); // begin serial communication with the RFID module rfidPort.begin(2400); } void loop() { // read in and parse serial data: if (rfidPort.available() > 0) { // if (readTag()) { // Serial.println(tagID); } } } /* This method reads the tag, and puts its ID in the tagID */ boolean readTag() { char thisChar = rfidPort.read(); // if (thisChar == startByte) { // if (rfidPort.readBytesUntil(endByte, tagID, tagLength)) { // return true; } } return false; }

Here’s how the code works:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.